package com.lingnan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lingnan.pojo.SelfActive;
import com.lingnan.mapper.SelfActiveMapper;
import com.lingnan.service.SelfActiveService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 个人活动表 服务实现类
 * </p>
 *
 * @author 梁兴达
 * @since 2022-03-06
 */
@Service
public class SelfActiveServiceImpl extends ServiceImpl<SelfActiveMapper, SelfActive> implements SelfActiveService {

    @Autowired
    private SelfActiveMapper selfActiveMapper;
    @Override
    public boolean addSelfActive(SelfActive selfActive) {
        selfActiveMapper.insert(selfActive);

        //ConcurrentHashMap<String, Object> objectObjectConcurrentHashMap = new ConcurrentHashMap<>();
        //objectObjectConcurrentHashMap.put("name",selfActive.getName());
        //List<SelfActive> selfActives = selfActiveMapper.selectByMap(objectObjectConcurrentHashMap);
        //Target target = new Target();
        //target.setActiveId(selfActives.get(0).getId());
        //if (!ObjectUtils.isEmpty(selfActives) && targetMapper.insert(target) > 0){
        //    return true;
        //}
        //return false;
        return true;
    }

    @Override
    public List<SelfActive> findAllByNo(String no) {
        QueryWrapper<SelfActive> wrapper = new QueryWrapper<>();
        wrapper.eq("no",no);
        return selfActiveMapper.selectList(wrapper);
    }
}
